home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- Newsgroups: comp.lang.c
- Subject: Re: fwrite help?
- Message-ID: <danpop.824668361@rscernix>
- From: danpop@mail.cern.ch (Dan Pop)
- Date: 18 Feb 96 18:32:41 GMT
- References: <4fmaig$7of@news.global1.net> <harmon.824165113@pegasus.montclair.edu>
- Organization: CERN European Lab for Particle Physics
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <harmon.824165113@pegasus.montclair.edu> harmon@pegasus.montclair.edu (Derek Harmon) writes:
-
- >first element in line, sizeof(char) for size insures compatibility on machines
- >where a character is more than one byte,
-
- Nonsense. sizeof(char) is 1 _by definition_. The real reason behind
- writing sizeof(char) is to improve the readability of the code for the
- human reader. To the compiler, sizeof(char) and 1 are equivalent in most
- contexts (they have the same value, but different types).
- >
- >: fwrite( line, sizeof(char), 8, fp);
- >
- > Of course, when they are contiguous in an array, and you know the sizeof a
- >char is 1 byte, it's much more efficient to say you want to write an 8-byte
- >block of memory once, instead of a 1-byte block of memory eight times.
-
- More nonsense. What makes one method much more efficient than the other?
- I couldn't find anything in the C standard to support this claim.
-
- If they succeed, both forms are equivalent. In case of failure, the first
- form will tell you how many bytes could be successfully written to the
- file while the second call won't be able to provide this information.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-